package library.operation;

import library.BookList;

import java.util.Scanner;

//删除书籍
public class DelOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("删除书籍");
        System.out.println("请输入要删除书籍的序号");
        int index = scanner.nextInt();
        int size = bookList.getSize();
        if (index < 0||index >= size) {
            System.out.println("输入序号错误!!!");
            return;
        }
        for (int i = index;i < size;i++) {
            bookList.setBook(i,bookList.getBook(i + 1));
        }
        bookList.setSize(size - 1);
    }
}
